﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="author" content="Cheresting" />
    <!-- 自动添加dayjs到全局 -->
    <script src="./publicJs/dayjs.min.js"></script>
    <!-- 自动添加vue到全局 -->
    <script src="./publicJs/vue.global.prod.js"></script>
    <!-- 自动添加axios到全局 -->
    <script src="./publicJs/axios.min.js"></script>
    <!-- 自动添加Cookies到全局 -->
    <script src="./publicJs/js.cookie.min.js"></script>
    <!-- 自动添加XLSX到全局 -->
    <script src="./publicJs/xlsx.core.min.js"></script>
    <!-- 自动添加QRCode到全局 -->
    <script src="./publicJs/qrcode.min.js"></script>

    <link rel="stylesheet" href="./publicJs/element-plus.index.css" />
    <!-- 自动添加ElementPlus到全局 -->
    <script src="./publicJs/element-plus.index.full.js"></script>
    <script src="./publicJs/index.iife.min.js"></script>
    <!-- 自动添加VXE到全局 -->
    <link rel="stylesheet" href="./publicJs/vxe/ui.style.min.css" />
    <link rel="stylesheet" href="./publicJs/vxe/table.style.min.css" />
    <script src="./publicJs/vxe/xe-utils.umd.min.js"></script>
    <script src="./publicJs/vxe/ui.index.umd.min.js"></script>
    <script src="./publicJs/vxe/table.index.umd.min.js"></script>

    <title>驱动器领料单</title>
  </head>

  <body>
    <div id="app">
      <vxe-button @click="printEvent">设置顶部和底部</vxe-button>
      <vxe-grid ref="gridRef" v-bind="gridOptions"></vxe-grid>
    </div>
  </body>
  <script type="module">
    const urlParams = new URLSearchParams(window.location.search)

    import myAxios from './myAxios/myAxios.js'
    import myAxiosWXPost from './myAxios/myAxiosWXPost.js'
    import { showSuccess, showWarning } from './hooks/useMyMessageBox.js'
    import v4 from './publicJs/uuidv4.js'
    const { createApp, ref, reactive, computed, onMounted, nextTick, watch } = Vue
    const { Bottom, Top, Right, Delete, Refresh, Calendar, Check, Search } = ElementPlusIconsVue

    import { GetMatCodeParamString } from './QDQZJH_JS/getMatCodeParamString.js'
    import { GetDataList2 } from './QDQZJH_JS/GetDataList2.js'
    const app = createApp({
      name: 'test',
      components: {},
      setup() {
        const gridRef = ref()
        const gridOptions = reactive({
          border: true,
          columns: [
            { type: 'seq', width: 70 },
            { field: 'name', title: 'Name' },
            { field: 'sex', title: 'Sex' },
            { field: 'age', title: 'Age' },
          ],
          data: [
            { id: 10001, name: 'Test1', role: 'Develop', sex: 'Man', age: 28, address: 'test abc' },
            { id: 10002, name: 'Test2', role: 'Test', sex: 'Women', age: 22, address: 'Guangzhou' },
            { id: 10003, name: 'Test3', role: 'PM', sex: 'Man', age: 32, address: 'Shanghai' },
            { id: 10004, name: 'Test4', role: 'Designer', sex: 'Women', age: 24, address: 'Shanghai' },
          ],
        })
        const printEvent = () => {
          // 打印样式
          const printStyle = `
  .title {
    text-align: left;   
    background-color: red;
    margin:0px;
    padding:0px;
  }
  .my-list-row {
    display: inline-block;
    width: 100%;
    background-color: red;
  }
  .my-list-col {
    float: left;
    width: 33.33%;
    height: 28px;
    line-height: 28px;
  }
  .my-top,
  .my-bottom {
    font-size: 12px;
  }
  .my-top {
    margin-bottom: 5px;
  }
  .my-bottom {
    margin-top: 30px;
    text-align: right;
  }
  `
          // 打印顶部内容模板
          const topHtml = `
  <h1 class="title">出货单据</h1>
  <div class="my-top">
    <div class="my-list-row">
      <div class="my-list-col">商品名称：vxe-table</div>
      <div class="my-list-col">发货单号：X2665847132654</div>
      <div class="my-list-col">发货日期：2020-09-20</div>
    </div>
    <div class="my-list-row">
      <div class="my-list-col">收货姓名：小徐</div>
      <div class="my-list-col">收货地址：火星第七区18号001</div>
      <div class="my-list-col">联系电话：10086</div>
    </div>
  </div>
  `
          // 打印底部内容模板
          const bottomHtml = `
  <div class="my-bottom">
    <div class="my-list-row">
      <div class="my-list-col"></div>
      <div class="my-list-col">创建人：小徐</div>
      <div class="my-list-col">创建日期：2020-09-20</div>
    </div>
  </div>
  `
          const $grid = gridRef.value
          if ($grid) {
            $grid.print({
              sheetName: '打印出货单据',
              style: printStyle,
              beforePrintMethod({ html }) {
                let result = topHtml + html + bottomHtml
                result = result.replace(
                  'class="vxe-table border--full is--print is--header" border="0" cellspacing="0" cellpadding="0"',
                  'border="2"',
                )
                console.log('result :>> ', result)
                return result
              },
            })
          }
        }

        return {
          gridRef,
          gridOptions,
          printEvent,
        }
      },
    })

    app.use(ElementPlus)
    app.use(VxeUI)
    app.use(VxeUITable)
    app.mount('#app')
  </script>
  <style>
    .marginTop10 {
      margin-top: 10px;
    }
    .keyword-highlight {
      background-color: #ffff00;
    }
    @media print {
      .vxe-table {
        border: 1px solid #000;
        border-collapse: collapse;
      }

      .vxe-table th,
      .vxe-table td {
        border: 1px solid #000;
      }
    }
    :root {
      --vxe-ui-table-border-color: red;
      --vxe-ui-table-border-width: 3px;
    }
  </style>
</html>
